php file upload problem [closed]

Posted by newcomer on Pro Webmasters See other posts from Pro Webmasters or by newcomer
Published on 2011-02-28T20:49:39Z Indexed on 2011/02/28 23:33 UTC
Read the original article Hit count: 231

Filed under:

This code works properly in my localhost. I am using xampp 1.7.3. but when I put it in the live server it shows Possible file upload attack!. 'upload/' is the folder under 'public_html' folder on the server. I can upload files via other script in that directory.

<?php

$uploaddir = '/upload/';//I used C:/xampp/htdocs/upload/ in localhost. is it correct here?
$uploadfile = $uploaddir . basename($_FILES['file_0']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['file_0']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\\n";
} else {
    echo "Possible file upload attack!\\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>

© Pro Webmasters or respective owner

Related posts about uploading